home *** CD-ROM | disk | FTP | other *** search
- global gDataBase, gTitleTable, gLabelTable, gNumberTitleTable, gDomain, gListObject
-
- on LoadDB
- OpenDatabaseReadWrite()
- DisplayErrorStatus()
- end
-
- on OpenDatabaseReadWrite
- if objectp(gDataBase) then
- gDataBase = 0
- end if
- if objectp(gTitleTable) then
- gTitleTable = 0
- end if
- if objectp(gLabelTable) then
- gLabelTable = 0
- end if
- if objectp(gNumberTitleTable) then
- gNumberTitleTable = 0
- end if
- gDataBase = new(xtra("V12Dbe"), the moviePath & "UrinarySystemDB.V12", "ReadWrite", EMPTY)
- gTitleTable = new(xtra("V12Table"), mGetRef(gDataBase), "Title_Words")
- gLabelTable = new(xtra("V12Table"), mGetRef(gDataBase), "Label_Words")
- gNumberTitleTable = new(xtra("V12Table"), mGetRef(gDataBase), "Number_Title")
- end
-
- on FindAll tableInstance, fieldname, TheOperator, findWord
- if objectp(tableInstance) then
- mSetIndex(tableInstance, fieldname & "Ndx")
- mSetCriteria(tableInstance, fieldname, TheOperator, findWord)
- mSelect(tableInstance)
- n = mSelectCount(tableInstance)
- value(gListObject).pltnnumberlist = mGetSelection(tableInstance, "LIST", mGetPosition(tableInstance), n)
- accumulator = []
- if value(gListObject).pltnnumberlist <> [] then
- repeat with rawListNum = 1 to value(gListObject).pltnnumberlist.count
- tmpList = value(getAt(getAt(value(gListObject).pltnnumberlist, rawListNum), 2))
- if tmpList <> VOID then
- repeat with listnum = 1 to tmpList.count
- if accumulator = [] then
- append(accumulator, getAt(tmpList, listnum))
- next repeat
- end if
- if getOne(accumulator, getAt(tmpList, listnum)) = 0 then
- append(accumulator, getAt(tmpList, listnum))
- end if
- end repeat
- end if
- end repeat
- end if
- value(gListObject).pltnnumberlist = duplicate(accumulator)
- sort(value(gListObject).pltnnumberlist)
- else
- put "Open database first..."
- end if
- end
-
- on PerformSimpleSearch TheOperator, findWord, Domain
- value(gListObject).pltnnumberlist = []
- if gDomain = "Titles" then
- FindAll(gTitleTable, "Title_Word", TheOperator, findWord)
- return value(gListObject).pltnnumberlist
- end if
- if gDomain = "Labels" then
- FindAll(gLabelTable, "Label_Word", TheOperator, findWord)
- return value(gListObject).pltnnumberlist
- end if
- end
-
- on FindTitle findNumber
- if objectp(gNumberTitleTable) then
- mSetIndex(gNumberTitleTable, "Image_Number" & "Ndx")
- mSetCriteria(gNumberTitleTable, "Image_Number", "=", findNumber)
- mSelect(gNumberTitleTable)
- n = mSelectCount(gNumberTitleTable)
- return mGetSelection(gNumberTitleTable, "LITERAL", 1, mSelectCount(gNumberTitleTable), TAB, RETURN, "Image_Title")
- end if
- end
-
- on JoinLists list1, list2
- newList = duplicate(list1)
- repeat with x in list2
- if getOne(newList, x) = 0 then
- add(newList, x)
- end if
- end repeat
- return newList
- end
-
- on IntersectLists list1, list2
- if ilk(list1, #linearList) and ilk(list2, #linearList) then
- newList = []
- repeat with x in list2
- if getOne(list1, x) <> 0 then
- append(newList, x)
- end if
- end repeat
- else
- alert("Both lists need to be of LINEAR type to join.")
- end if
- return newList
- end
-
- on DisplayErrorStatus
- errCode = mStatus(xtra("V12dbe"))
- if errCode <> 0 then
- alert(mError(xtra("V12dbe")))
- else
- put "no errors detected"
- end if
- end
-